/* 
 * File:   Contenu.cpp
 * Author: H4314
 * 
 * Created on 3 avril 2012, 09:46
 */

#include "Content.h"


Content::Content(const string & text)
: text(text)
{
    NODES++;
#ifdef SHOW_FREE
        cout << "ADD: CONTENT(" << text << ")"<< endl;
#endif
}

Content::Content(const Content& orig) {
    NODES++;
#ifdef SHOW_FREE
        cout << "ADD: CONTENT(" << text << ")"<< endl;
#endif
    this->text = orig.text;
}

Content::~Content() {
    NODES--;
#ifdef SHOW_FREE
        cout << "DEL: CONTENT(" << text << ")"<< endl;
#endif
}

// Getters
const string & Content::getText() const {
    return text;
}

// Setters
void Content::setText(const string & newText){
    this->text = newText;
}

void Content::Print(ostream & stream) const {
    stream << text;
}

void Content::Tree(ostream & stream, int level) const {
    string indent;
    
    // Gestion du niveau d'indentation
    for(int i = 0; i < level; i++)
        indent += "│\t";
    level++;
    
    stream << indent << "│ " << *this << endl;
}

void Content::Draw(ostream & stream, int level, bool colored) const {
    // Gestion du niveau d'indentation
    for(int i = 0; i < level; i++)
        stream << "  ";
    
    stream << text;
    
    if(level != 0)
        stream << endl;
}

string Content::createValidationString() const {
    return "#PCDATA";
}

bool Content::validationWithDTD(map<string,regex> *regexs) const {
    return true;
}
